package com.zy.springboot_nanhua4.controllers;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResponseResult<T> {
    private int code;
    private String msg;
    private T data;

    public static ResponseResult ok() {
        return ResponseResult.builder().code(1).msg("操作成功").build();
    }

    public static ResponseResult ok(String message) {
        return ResponseResult.builder().code(1).msg(message).build();
    }

    public static ResponseResult error() {
        return ResponseResult.builder().code(0).msg("操作失败").build();
    }

    public static ResponseResult error(String message) {
        return ResponseResult.builder().code(0).msg(message).build();
    }

    public ResponseResult<T> setData(T t) {
        this.data = t;
        return this;
    }
}
